#pragma once

#include "utilities/utilities.h"
#include "Component/Util/AppModuleModel.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <QList>
#include <QPair>
#include <time.h>

class GlobalStatistic;

class HistoryModel : public AppModuleModel
{
public:
	HistoryModel(AppModule* moduleref);
	void handlePackets(const PacketArray& packets);

	QList<int> queryPackets(int beg,int end);
	QList<int> queryBytes(int beg,int end);
	int snap();
	void setBeginTime();

	int getLength() {
		return m_PacketPt.size();
	}
	//void setEndTime();

	time_t getBeginTime() const {
		return m_BegTime;
	}
	
	QList<int>& getByteList() {
		return m_BytePt;
	}

	QList<int>& getPacketList() {
		return m_PacketPt;
	}

	int queryPacket(int index) const{
		return m_PacketPt.at(index);
	}

	int queryByte(int index) const {
		return m_BytePt.at(index);
	}

protected: 
	void onModuleOptChanged() {}
	void onGlobalOptChanged();

private:
	time_t m_BegTime;
	time_t m_PrePt;
	QList<int> m_BytePt;
	QList<int> m_PacketPt;
	shared_ptr<GlobalStatistic> m_Statistic;
	qint64 m_PreBytes,m_PrePackets;
	int m_Counter;
	//int m_Diff;
};